package org.projectwithoutname.handler;
import model.Entity;

import org.eclipse.core.commands.AbstractHandler;
import org.eclipse.core.commands.ExecutionEvent;
import org.eclipse.core.commands.ExecutionException;
import org.eclipse.core.commands.IHandler;
import org.eclipse.ui.IWorkbenchPage;
import org.eclipse.ui.IWorkbenchWindow;
import org.eclipse.ui.handlers.HandlerUtil;
import org.projectwithoutname.ui.pages.SinopsePage;
import org.projectwithoutname.ui.pages.input.EntityEditorInput;
import org.projectwithoutname.ui.view.InformationView;


public class ReloadHandler extends AbstractHandler implements IHandler {

	@Override
	public Object execute(ExecutionEvent event) throws ExecutionException {
		IWorkbenchWindow window = HandlerUtil.getActiveWorkbenchWindow(event);
		IWorkbenchPage page = window.getActivePage();
		InformationView informationView = (InformationView) page.findView(InformationView.ID);
		Entity newEntity = informationView.getEntity();
		EntityEditorInput input = new EntityEditorInput(newEntity);
		
		SinopsePage sinopsePage = (SinopsePage) page.findEditor(input);
		sinopsePage.chageInput(newEntity);
		
		return null;
	}
}
